<template>
  <div>
        <div>
          <el-dialog
              width="30%"
              title="填写收款金额"
              style="text-align: center;margin-top: 200px"
              :visible.sync="innerVisible"
              append-to-body>
            <div style="margin-top: 15px">
              <el-input
                  placeholder="请填写收款金额"
                  v-model="totalMoney"
                  oninput="value=value.replace(/[^\d]/g,'')"
                  style="width: 400px"
                  clearable>
              </el-input>
            </div>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="confirm">确认</el-button>
              <el-button @click="innerVisible = false,totalMoney = '' ">取消</el-button>
            </div>
          </el-dialog>
        </div>
        <div>
          <el-table
              :data="tableData"
              height="600"
              border
              style="width: 100%">
            <el-table-column
                prop="fid"
                label="财务编号"
                width="180">
            </el-table-column>
            <el-table-column
                prop="fkOrderId"
                label="订单号"
                width="180">
            </el-table-column>
            <el-table-column
                prop="lnumber"
                label="物流号"
                width="180">
            </el-table-column>
            <el-table-column
                prop="pname"
                label="产品名">
            </el-table-column>
            <el-table-column
                prop="fsumMoney"
                label="总金额">
            </el-table-column>
            <el-table-column
                prop="fstate"
                label="状态">
              <template slot-scope="scope">
                <p v-if="scope.row.fstate == 0" >未收款</p>
                <p v-if="scope.row.fstate == 1" >已收款</p>
                <p v-if="scope.row.fstate == 2" >已失效</p>
              </template>
            </el-table-column>
            <el-table-column
                prop="fpayDate"
                label="收款日期">
            </el-table-column>
            <el-table-column
                fixed="right"
                label="操作"
                width="100">
              <template slot-scope="scope">
                <el-button v-if="scope.row.fstate == 0" @click="receiptGoods(scope.row)" type="text" size="small">收款</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>

  </div>
</template>

<script>
import Navigation from "@/components/Navigation";
import HeaderMenu from "@/components/HeaderMenu";
export default {
  name: "Finance",

  data(){
    return{
      tableData: [],
      innerVisible:false,
      sSaleProductId:"",
      totalMoney:"",
    }
  },
  mounted() {
    this.init()
  },
  methods:{
    init(){
      //供应商id
      let supplierId = "s100"
      this.$axios.get("api/financeInfo/" + supplierId).then(
          r=>{
            this.tableData = r.data
          }
      )
    },
    receiptGoods(row){
        this.sSaleProductId = row.ssaleProductId
      this.innerVisible = true
    },
    confirm(){
      let f = new FormData()
      f.append("sSaleProductId",this.sSaleProductId)
      f.append("fSumMoney",this.totalMoney)
      this.$axios.put("api/receivePayment",f).then(
          r=>{
            this.$message.info(r.data.message)
          }
      )
      this.totalMoney = ""
      this.innerVisible = false
    },
  }
}
</script>

<style scoped>

</style>